"""code schema"""

from pydantic import BaseModel

from forward.extend.pydantic.base import BaseSchema
from forward.model.schemas.lucky.code import CodeOutSchema
from forward.utils.tools import ToolsUtil


class CodeAddInSchema(BaseSchema):
    """code 码号添加参数"""


class CodeEditInSchema(BaseSchema):
    """code 码号编辑参数"""

    id: int


class CodeListInSchema(BaseSchema):
    """code 码号列表参数"""

    export: int | None = None
    merchant_id: int | None = None
    prize_id: int | None = None
    code: str | None = None
    code_no: str | None = None
    status: int | None = None
    page_no: int = 1
    page_size: int = 20
    model_config = {
        "alias_generator": ToolsUtil.to_lower_camel,
        "populate_by_name": True,
    }


class CodeDetailInSchema(BaseModel):
    """
    码号详情查询
    """

    id: int


class CodeDeleteInSchema(BaseModel):
    """
    码号删除参数
    """

    id: int


class CodeDetailOutSchema(CodeOutSchema):
    """
    码号详情输出
    """

    merchant_name: str | None = None
    prize_name: str | None = None
    prize_level_text: str | None = None
    code_no: str | None = None
    activity_title: str | None = None
    status_text: str | None = None

    model_config = {
        "alias_generator": ToolsUtil.to_lower_camel,
        "populate_by_name": True,
    }


class GenerateInSchema(BaseModel):
    """
    码号生成参数
    """

    num: int
    begin_num: int
    end_num: int
    prefix: str


class CodeStatusInSchema(BaseModel):
    """
    码号状态修改
    """

    id: int
    status: int


class ActivityExportInSchema(BaseSchema):
    """
    码号导出参数
    """

    num: int
    begin_num: int
    end_num: int
    prefix: str


class ActivityCheckInSchema(BaseSchema):
    """
    码号检测参数
    """

    prefix: str
    start_code_id: int
    end_code_id: int


class CodeStatisticsInSchema(BaseSchema):
    activity_id: int


class CodeResetInSchema(BaseSchema):
    activity_id: int


class CodeCompleCodeNoInSchema(BaseSchema):
    prefix: str
    code_no_start: int
    num: int
